﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FurnitureSystem
{
    public partial class frmThemDonDatHang : Form
    {
        SqlConnection conn;
        SqlCommand cmd;
        SqlDataReader dr;

        public frmThemDonDatHang()
        {
            InitializeComponent();
        }

        private void BtnThem_Click(object sender, EventArgs e)
        {
            if (txtMaDon.Text == "" || txtMaSP.Text == "" || txtSoluong.Text == "" || txtSotien.Text == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin đơn đặt hàng mới");
            }
            else
            {
                conn = connect.Getconect();
                conn.Open();
                string sql = "insert into Orderline values ('" + Int32.Parse(txtMaDon.Text) + "','" + txtMaSP.Text + "','" + Int32.Parse(txtSoluong.Text) + "','" + Int32.Parse(txtSotien.Text) + "')";
                //MessageBox.Show(sql);
                cmd = new SqlCommand(sql, conn);
                dr = cmd.ExecuteReader();
                MessageBox.Show("Đã thêm đơn đăt hàng vào csdl");
                conn.Close();
                txtMaDon.Text = "";
                txtMaSP.Text = "";
                txtSoluong.Text = "";
                txtSotien.Text = "";
            }
        }

        private void BtnThoat_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
    }
}
